<?php
require_once '../config/config.php';
require_once '../config/connexion_db.php';

if (isset($_POST['envoyer'])){
     if(isset($_POST['liste_contact_rs']))      $liste_contact_rs=$_POST['liste_contact_rs'];
        else      $liste_contact_rs="";
     if(isset($_POST['date']))      $date=$_POST['date'];
        else      $date="";
     if(isset($_POST['heure']))      $heure=$_POST['heure'];
        else      $heure="";
     if(isset($_POST['min']))      $min=$_POST['min'];
        else      $min="";
     if(isset($_POST['type_rdv']))      $type_rdv=$_POST['type_rdv'];
        else      $type_rdv="";
        if(isset($_POST['objet']))      $objet=$_POST['objet'];
        else      $objet="";
     if(isset($_POST['observation']))      $observation=$_POST['observation'];
        else      $observation="";
        $horaire = $heure.":".$min.":00";
      $sql = "INSERT INTO carnet_adresses.rendez_vous(id, id_contact, rdv_date, heure, type_rdv, objet, observations)  VALUES (NULL, $liste_contact_rs, '$date', '$horaire', '$type_rdv', '$objet', '$observation')";
      $envoi_requete = mysqli_query($connexion_serveur, $sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
//      echo ' Nouvelle entreprise enregistrée';
    }
?>

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>AJOUTER UN RENDEZ-VOUS</title>
        <link href="../bootstrap/css/bootstrap.css" type="text/css" rel="stylesheet">
        <link href="../css/style.css" type="text/css" rel="stylesheet">
        <!--<link href="../css/style.css" type="text/css" rel="stylesheet">-->
    </head>
    <body>
         <?php 
        require_once "../config/css_js_bootstrap/css_js_bootstrap.php"; 
        require_once '../config/menus/menu_principal.php';
        ?>
        <div id="fiche">
        <br><div id="div2">
        <a href="liste_rdv.php">Retour à la liste des rendez-vous</a>
        <br></div>
        <br><div id="div2">
            <h3>Ajouter un rendez-vous</h3>
        <br>
        <form name="ajouter_rdv" id="ajouter_rdv" method="post" action="" enctype="multipart/form-data">
            <table>
                <tr>
                    <td class="col1">Contact:</td>
                    <td class="col2"><select name="liste_contact_rs"> 
                        <?php 
                        //REQUETE SQL
                        $sql_ent2 = "SELECT * FROM entreprises, contacts WHERE entreprises.id = contacts.id_entreprise";
                        $req_ent2 = mysqli_query($connexion_serveur, $sql_ent2);
                        while ($data_ent2 = mysqli_fetch_assoc($req_ent2)){
                            ?>
                        <option value="<?php echo $data_ent2['id']; ?>"><?php echo $data_ent2['nom']; ?> <?php echo $data_ent2['prenom']; ?>   =>   <?php echo $data_ent2['raison_sociale']; ?></option>
                            <?php
                        }?>
                        </select></td>
                </tr>
                <tr>
                    <td class="col1">Date:</td>
                    <td class="col2"><input type="date" name="date" id="date"></td>
                </tr> 
                <tr>
                    <td class="col1">Heure:</td>
                    <td class="col2"><input type="text" name="heure" id="heure" maxlength="2" size="2"> : <input type="text" name="min" id="min" maxlength="2" size="2"></td>
                </tr>    
                <tr>
                    <td class="col1">Type:</td>
                    <td class="col2"><select name="type_rdv"> 
                            <option >Entretien</option>
                            <option >Vente</option>
                            <option >Client</option>
                            <option >Stage</option>
                            <option >Service</option>
                            <option >Ecole</option>
                        </select></td>
                </tr>
                <tr>
                    <td class="col1">Objet:</td>
                    <td class="col2"><input type="text" name="objet" id="objet" maxlength="30" size="40"></td>
                </tr> 
                <tr>
                    <td class="col1">Observation:</td>
                    <td class="col2"><textarea name="observation" id="observation" cols="60" rows="5" placeholder="Observation..."></textarea></td>
                </tr> 
                    <td class="col1"></td>
                    <td class="col2"><input type="submit" name="envoyer" value="Envoyer" /></td>
                </tr>
            </table>   
            
        </form>
        </div>
        </div>
    </body>
</html>
